package com.customers.controller;

import com.customers.entity.Customer;
import com.customers.service.CustomerService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/deleteContact")
public class ContactDelServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String deletedId = request.getParameter("deletedId");
        int id = Integer.parseInt(deletedId);

        try{
            CustomerService customerService = (CustomerService) request.getServletContext().getAttribute("CustomerService");
            String sql = "contactDel";
            Customer customer = new Customer();
            customer.setId(id);
            customerService.deleteContact(customer,sql);
//            ContactFormService.deleteContact(id);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
